﻿using DotNetCore.CAP;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace O.M.Production.Read.API.Controllers
{
    /// <summary>
    /// 检查心跳
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HealthController : ControllerBase
    {
        public readonly ICapPublisher _capPublisher;

        public HealthController(ICapPublisher capPublisher)
        {
            _capPublisher = capPublisher;
        }

        /// <summary>
        /// 心跳检查
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Index()
        {
            return Ok(DateTime.Now);
        }
        /// <summary>
        /// 发布者
        /// </summary>
        /// <param name="a">参数</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Create(int a)
        {
            _capPublisher.Publish("ProductionAdd", a);
            return Ok("");
        }
    }
}
